/**
 * @author Kristian Mandrup
 * @date May 25, 2009
 * @version 0.1
 * 
 * m3gen :: Base
 * 
 * - Abstract Base object
 * 
 * - Contains general utility functions
 * - Specific Objects can use this object as a Base, extending it using inherits
 */

/**
 * 
 * @param {Object} options
 * 
 */
m3gen.Base = function(options) {
	if (arguments.length < 1 || m3gen.util.invalidOptions(options))
		return;		
	this.init(options);
}

m3gen.Base.prototype.init = function(createOptions){
	if (arguments.length < 1 || m3gen.util.invalidOptions(createOptions))
		console.log('Base.init: bad createOptions');
	this.setGlobalExecState(createOptions.globalExecState);	
	
	this.setCreateOptions(this.getObjDef(createOptions.constructors,createOptions));
	this.setExceptionHandler(createOptions.exceptionHandler);
	this.setEventController(createOptions.eventController);
}

/**
 * Event handler
 * @param {Object} event
 */
m3gen.Base.method('handleEvent', function(event) {
		this.getEventController().handle(event);
	}
);

